/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"29136026-43DA-460E-ACB8-22FB5459E1CF",variableType:4}
 */
var gConsorcio = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"82F74C29-6D5F-448E-AB7F-B06C8DBFB6F9",variableType:4}
 */
var gAdministracion = 1;

/**
 * @properties={typeid:24,uuid:"D625896B-5F08-43F0-ADD4-BDB0B8430FA2"}
 */
function gBorrar() {
	if (globals.DIALOGS.showQuestionDialog('Seguro','¿Desea borrar este registro?','Si','No') == 'Si')
	{
		currentcontroller.deleteRecord()
	}
}

/**
 * 
 * @param {Number} unidad
 * @param {Number} cod_mov
 * @param {String} concepto
 * @param {Number} importe
 * @param {Date} fecha
 * 
 * @properties={typeid:24,uuid:"2636E218-D6D7-47B2-BBEE-CF84FA61724C"}
 */
function gAltaCtacte(unidad,cod_mov,concepto,importe,fecha) {
	/** @type {JSFoundSet<db:/consorcios/cta_cte>}*/
	var $cc = databaseManager.getFoundSet('consorcios','cta_cte')
	$cc.newRecord()
	$cc.unidad_id 	= unidad
	$cc.cod_mov 	= cod_mov
	$cc.concepto 	= concepto
	$cc.importe 	= importe
	$cc.fecha		= fecha
	if (cod_mov == 2)
		$cc.importe_signo = importe
	else
		$cc.importe_signo = importe	* (-1)
}

/**
 * Callback method for when solution is opened.
 *
 * @properties={typeid:24,uuid:"6BB0801D-CADB-4D78-8771-77FFDCC79E7D"}
 */
function onSolutionOpen() {
	application.putClientProperty(APP_UI_PROPERTY.TABLEVIEW_WC_DEFAULT_SCROLLABLE, true)
	var $sql = 'SELECT descripcion, administracion_id FROM administraciones'
	var $ds = databaseManager.getDataSetByQuery('consorcios',$sql,null,-1)
	application.setValueListItems('administraciones',$ds)
	globals.gAdministracion = $ds.getValue(1,2)
	cambiarAdministracion()
}

/**
 * @properties={typeid:24,uuid:"C82FFE43-07D2-4318-876E-7C12A23059AB"}
 */
function cambiarAdministracion()
{
	databaseManager.addTableFilterParam('consorcios',null,'administracion_id','=',globals.gAdministracion,'FILTRO_ADMINISTRACIONES')
	var $sql = 'SELECT descripcion, consorcio_id FROM consorcios WHERE administracion_id = ?'
	var $args = [globals.gAdministracion]
	var $ds = databaseManager.getDataSetByQuery('consorcios',$sql,$args,-1)
	application.setValueListItems('consorcios',$ds)
	globals.gConsorcio = $ds.getValue(1,2)
	databaseManager.addTableFilterParam('consorcios',null,'consorcio_id','=',globals.gConsorcio,'FILTRO_CONSORCIOS')
}
